<template>
	<scroll-view class="scroll-view" scroll-y @scrolltolower="getList">
		<view class="detail-box">
			<emptyWaybill v-if="pageList.length==0" />
			<dataDetail v-for="(item,i) in pageList" :appeal="appealShow" :key="i" :items="item"
				@appeal="appeal(item)" />
		</view>
	</scroll-view>
</template>
<script>
	import dataDetail from "@/components/tool-card/data-detail";
	import emptyWaybill from "@/components/tool-empty/waybill";
	export default {
		components: {
			dataDetail,
			emptyWaybill
		},
		data() {
			return {
				list: [],
				current: 0,
				pageList: [],
				appealShow: false,
			}
		},
		computed: {
			total() {
				return this.list.length;
			},
		},
		methods: {
			getList() {
				this.current++;
				let end = this.current * 20;
				let start = end - 20;
				const addList = this.list.slice(start, end);
				// console.log(addList);
				this.pageList.push(...addList);
			},
			appeal(item) {
				const params = {
					...item,
				}
				delete params.archiveDetailVOList;
				this.$goBack('/pages/dgs_qy/safety-code/appeal?params=' + JSON.stringify(params))
			},
			initData() {
				if (this.item.archiveDetailVOList.length) {
					this.list = [];
					this.pageList = [];
					this.current = 0;
					this.$api.archiveItemDetailList(this.item.archiveDetailVOList).then(res => {
						this.list = res.data.data;
						this.getList();
					})
				}
			}
		},
		onLoad(e) {
			// console.log(e);
			const tempData = this.$store.getters.getTempData;
			if (e.type == 'history') {
				this.item = tempData.historyCycle[e.i];
			} else {
				this.item = tempData.archiveItemTable[e.i];
			}
			if (e.appeal) {
				this.appealShow = true;
			}
			// 设置当前查看的扣分详情类型
			uni.setNavigationBarTitle({
				title: this.item.indicatorItem
			})
			this.initData();
		},
	}
</script>
<style lang="scss">
	.scroll-view {
		height: 100vh;

		.detail-box {
			box-sizing: border-box;
			padding: 30rpx;
			background: #f2f2f2;
			position: relative;

			.item-box {
				margin-bottom: 30rpx;
			}
		}
	}
</style>